# This file shows how to operate stack images
# Written by Yueyi Zhang

from ij import IJ, ImagePlus, ImageStack  
from ij.process import ByteProcessor  
from array import zeros 
from ij.gui import Roi

 # Get current ImagePlus
imp = IJ.getImage() 
 # Get current ImageStack
stack = imp.getImageStack()  

 # Print information
print "Number of slices:", imp.getNSlices()
print "File name:", imp.getTitle()
print "Width:", imp.getWidth()
print "Height:", imp.getHeight()  

width = imp.getWidth()
height = imp.getHeight()

stack2 = ImageStack(width, height * 2)

for k in xrange(1, imp.getNSlices() + 1):
	oldbp = stack.getProcessor(k).convertToByteProcessor()
	pixels = zeros('b', width * height * 2)

	bp = ByteProcessor(width, height * 2, pixels, None)
	# Insert original image to black canvas
	bp.insert(oldbp, 0, k)
	stack2.addSlice(None, bp)
	
imp2 = ImagePlus("Converted", stack2)
imp2.show()